/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package commands;

import Persistence.ConversationFactory;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import servidorped.User;

/**
 *
 * @author Micosil
 */
public class gethistory implements Command {

    @Override
    public boolean execute(String[] stringlist, User user) {
        List<String> conversationDates = ConversationFactory.getConversationPersistence().findConversationsByUser(user.getUserName());
        for(String oneString: conversationDates){
            user.getUserSender().setToSend(oneString);
        }
        if (conversationDates.isEmpty())
            user.getUserSender().setToSend("You have not participated in any conversations.");
        Logger.getGlobal().log(Level.INFO, "User {0} requested and received his conversation names.", user.getUserName());
        return true;
    }
    
}
